#ifndef  HELPER_OBJECT_ITERATOR_H
#define  HELPER_OBJECT_ITERATOR_H

namespace helper {
namespace object {

/**
 * Iterator interface
 * @param <ValueType>  element type of Iterator
 *
 * @since 0.1
 */
template<typename ValueType>
class Iterator {
public:
    typedef ValueType ElementType;

    Iterator(){}
    virtual ~Iterator(){}

    /**
     * test the iterator has next element
     * @return true if the next element is not null
     */
    virtual bool hasNext() const = 0;
    /**
     * get the next element 
     * @return const value ref of the next element
     */
    virtual const ElementType & next() = 0;

public:
    virtual bool isEnd(const ElementType & value) const {
        return &nullObj == &value;
    }

protected:
    virtual ValueType & getNullObjRef() const {
        return nullObj;
    }

private:
    static ValueType nullObj;
};

template<typename ValueType>
ValueType Iterator<ValueType>::nullObj;

} // end of namespace object
} // end of namespace helper

#endif   /* HELPER_OBJECT_ITERATOR_H */
